from odoo import api, fields, models, _
from odoo.exceptions import ValidationError

class MrpWorkcenterProductivity(models.Model):
    _inherit = "mrp.workcenter.productivity"

    def button_block(self):
        active_id = dict(self._context).get('active_id', None)
        workorder_id = self.workorder_id
        if active_id:
            workorder_id = self.env['mrp.workorder'].search([('id', '=', active_id)])
        if workorder_id.is_lock:
            raise ValidationError('Sale order is lock, please unlock')
        if workorder_id.is_lock:
            raise ValidationError('Sale order is lock, please unlock')
        return super().button_block()
